require "Common/class"
require "Common/Base/BaseCtrl"
require "View/LoginPanel"
--登录面板控制类
--create by lwt
--date 2018-4-21
LoginCtrl = class("LoginCtrl",BaseCtrl)

function LoginCtrl:Awake(resName)
	self.curPanel = LoginPanel.New("LoginPanel")
	self.super:Awake(resName,self)
end

function LoginCtrl:ShowPanel(data)
	self.super.ShowPanel(self,data)
end

function LoginCtrl:InitCtrl()
end

function LoginCtrl:AddUIEvent()
	self.luaBehaviour:AddClick(self.curPanel.LoginBtn,function ()
		if ButtonHandle:ClickFastHand() then return end
		self:Click_login()
	end)
end

function LoginCtrl:AddListener()
	
end

function LoginCtrl:RemoveListener()
	
end

function LoginCtrl:Click_login()

	CtrlManager.ShowPanel(CtrlNames.Hall,nil,2)
	--self:ClosePanel()

	local proto = login_pb.loginReq()
	proto.userid = "testName"
	proto.passwd = "123123"
	local msg = proto:SerializeToString()
	look("===========msg===========",msg,tonumber(CommonMain_pb.LOGIN))
	local data = ByteBuffer.New()
	data:WriteInt(tonumber(CommonMain_pb.LOGIN))
	data:WriteString(msg)
	networkMgr:SendMessage(data)
end
